package service

import (
	"testgin0012/userManager/model"
)

type CusTomerService struct {
	customers  map[int]*model.Customer
	customerId int
}

func MakeCusTomerService() *CusTomerService {
	return &CusTomerService{
		customers: make(map[int]*model.Customer),
	}
}

func (c *CusTomerService) Add(customer *model.Customer) {
	c.customerId++
	customer.Id = c.customerId
	c.customers[customer.Id] = customer
}

func (c *CusTomerService) List() map[int]*model.Customer {
	return c.customers
}

func (c *CusTomerService) Find(id int) (*model.Customer, bool) {
	if customer, ok := c.customers[id]; ok {
		return customer, true
	}
	return nil, false
}

func (c *CusTomerService) Delete(id int) {
	delete(c.customers, id)
}

func GetTableHeader() string {
	return model.GetTableHeader()
}
